#include "mem.h"

static int offset = 0;

void memcopy(uint8_t *src, uint8_t *dst, int len) {
    int i;
    for (i = 0; i < len; i++) {
        dst[i] = src[i];
    }
}

void *kmalloc(int size, int align) {
    if(align) {
        // 4k对齐
        offset = (offset + 0xfff) & 0xfffff000;
    }
    void *res = (void *)(ALLOC_START_ADDR + offset);
    offset += size;
    return res;
}

int memcmp(uint8_t* p1, uint8_t* p2, int len) {
    int i;
    for(i = 0; i < len; i++){
        int diff = p1[i] - p2[i];
        if(diff != 0) return diff;
    }
    return 0;
}
